<template>
<el-card shadow="never" class="aui-card--fill">
    <div class="mod-IsTraffic__istraffic">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()" style="margin-bottom:20px">
            <el-form-item>
                <el-input v-model="dataForm.nameStart" placeholder="起点" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.nameEnd" placeholder="终点" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.startArea" placeholder="发车点" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <SelectComponent v-model="dataForm.type" placeholder="交通工具类型" dictType="traffic_type">
                </SelectComponent>
            </el-form-item>
            <el-form-item>
                <el-button @click="getDataList()">{{ $t("query") }}</el-button>
            </el-form-item>
            <el-form-item v-if="$hasPermission('sys:istraffic:export')">
                <el-button type="primary" @click="exportHandle()">{{
            $t("export")
          }}</el-button>
            </el-form-item>
            <el-form-item>
                <el-button v-if="$hasPermission('sys:istraffic:save')" type="primary" @click="addOrUpdateHandle()">{{ $t("add") }}</el-button>
            </el-form-item>
            <el-form-item>
                <el-button v-if="$hasPermission('sys:istraffic:delete')" type="danger" @click="deleteHandle()">{{ $t("deleteBatch") }}</el-button>
            </el-form-item>
        </el-form>
        <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle" style="width: 100%">
              <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
            <el-table-column type="expand">
                <template slot-scope="props">
                    <el-form label-position="left" class="demo-table-expand" >
                        <el-form-item label="起点名称">
                            <span>{{ props.row.nameStart }}</span>
                        </el-form-item>
                        <el-form-item label="终点名称">
                            <span>{{ props.row.nameEnd }}</span>
                        </el-form-item>
                        <el-form-item label="发车点">
                            <span>{{ props.row.startArea }}</span>
                        </el-form-item>
                        <el-form-item label="时刻表">
                            <span>{{ props.row.time }}</span>
                        </el-form-item>
                        <el-form-item label="交通工具类型">
                            <span>{{ props.row.typeName }}</span>
                        </el-form-item>
                        <el-form-item label="温馨提示">
                            <span>{{ props.row.tips }}</span>
                        </el-form-item>
                        <el-form-item label="详情介绍">
                            <span>{{ props.row.info }}</span>
                        </el-form-item>
                          <el-form-item label="备注">
                            <span>{{ props.row.remark }}</span>
                        </el-form-item>
                    </el-form>
                </template>
            </el-table-column>
            <el-table-column prop="nameStart" label="起点名称" header-align="center" sortable="custom" :show-overflow-tooltip="true" min-width="120" align="center"></el-table-column>
            <el-table-column prop="nameEnd" label="终点名称" header-align="center" sortable="custom" :show-overflow-tooltip="true" min-width="120" align="center"></el-table-column>
            <el-table-column prop="startArea" label="发车点" header-align="center" :show-overflow-tooltip="true" min-width="120" align="center"></el-table-column>
            <el-table-column prop="time" label="时刻表" :show-overflow-tooltip="true" min-width="120" header-align="center" align="center"></el-table-column>
            <el-table-column prop="typeName" label="交通工具类型" header-align="center" align="center"></el-table-column>
            <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
                <template slot-scope="scope">
                    <el-button v-if="$hasPermission('sys:istraffic:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t("update") }}</el-button>
                    <!-- <el-button type="text" size="small" @click="viewHandle(scope.row)"
              >查看</el-button
            > -->
                    <el-button v-if="$hasPermission('sys:istraffic:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t("delete") }}</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
        </el-pagination>
        <!-- 弹窗, 新增 / 修改 -->
        <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" :disabled="disabled" @changeDisabled="disabled = false"></add-or-update>
    </div>
</el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./istraffic-add-or-update";
export default {
    mixins: [mixinViewModule],
    data() {
        return {
            disabled: false,

            mixinViewModuleOptions: {
                getDataListURL: "/sys/istraffic/page",
                getDataListIsPage: true,
                exportURL: "/sys/istraffic/export",
                deleteURL: "/sys/istraffic",
                deleteIsBatch: true,
            },
            dataForm: {},
        };
    },
    watch: {},
    components: {
        AddOrUpdate,
    },
    methods: {
        viewHandle(row) {
            this.addOrUpdateVisible = true;
            this.disabled = true;
            this.$nextTick(() => {
                this.$refs.addOrUpdate.visible = true;
                // this.$refs.addOrUpdate.dataForm = row;
                this.$refs.addOrUpdate.dataForm.id = row.id;
                this.$refs.addOrUpdate.dataForm.details = true;
                this.$refs.addOrUpdate.init()
            });
        },
    },
};
</script>
<style scoped>
.demo-table-expand{
  margin-left:60px;
}
 ::v-deep .el-form-item{margin-bottom:5px}
 ::v-deep .el-form-item__label{
    color:#99a9bf;
    width:100px;
  }
</style>
